<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="所属公司">
        <TenantChoose @loaded="search" v-model="form.tenant_id" />
      </el-form-item>
      <br />
      <!-- <el-form-item label="状态">
        <el-radio-group v-model="form.status" @change="search">
          <el-radio-button :label="0">全部</el-radio-button>
          <el-radio-button :label="100">
            待审核
            <span v-if="watingJudge > 0" class="radio-group-tips">
              {{ watingJudge }}
            </span>
          </el-radio-button>
          <el-radio-button :label="400">
            待打款
            <span v-if="watingPay > 0" class="radio-group-tips">{{
              watingPay
            }}</span>
          </el-radio-button>
          <el-radio-button :label="600">已拒绝</el-radio-button>
          <el-radio-button :label="500">已完成</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br /> -->
      <el-form-item label="申请时间">
        <el-date-picker
          v-model="form.startDate"
          type="date"
          placeholder="开始"
          value-format="YYYY-MM-DD"
          style="width: 168px"
        />
      </el-form-item>
      <el-form-item label="申请时间">
        <el-date-picker
          v-model="form.endDate"
          type="date"
          placeholder="结束"
          value-format="YYYY-MM-DD"
          style="width: 168px"
        />
      </el-form-item>

      <el-form-item label="审核时间">
        <el-date-picker
          v-model="form.startPaidDate"
          type="date"
          placeholder="开始"
          value-format="YYYY-MM-DD"
          style="width: 168px"
        />
      </el-form-item>
      <el-form-item label="审核时间">
        <el-date-picker
          v-model="form.endPaidDate"
          type="date"
          placeholder="结束"
          value-format="YYYY-MM-DD"
          style="width: 168px"
        />
      </el-form-item>
      <br />
      <el-form-item label="名字">
        <el-input v-model="form.realname" clearable style="width: 168px" />
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="form.tel" clearable style="width: 168px" />
      </el-form-item>

      <el-form-item label-width="16px">
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { useFormData } from '@/utils/use-form-data';

  const emit = defineEmits(['search']);
  const props = defineProps({
    where: Object
  });
  /** 表单数据 */
  const [form] = useFormData({
    status: 100,
    startDate: '',
    endDate: '',
    startPaidDate: '',
    endPaidDate: '',
    realname: '',
    tel: '',
    tenant_id: 0
  });
  if (props.where) {
    form.startDate = props.where.startDate ?? '';
    form.endDate = props.where.endDate ?? '';
    form.startPaidDate = props.where.startPaidDate ?? '';
    form.endPaidDate = props.where.endPaidDate ?? '';
    form.status = 0;
  }

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };
</script>
